<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta name="author" content="AndyGuo" />
    <title>我的优质老铁</title>
    <meta name="keywords" content="AndyGuo" />
    <meta name="description" content="AndyGuo" />
    <link href="https://lib.baomitu.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <link rel="stylesheet" href="css/animate.css?v=3.51">
    <link rel="stylesheet" href="css/style.css?v=1.57">

</head>

<body>
    
<div id="app" class="page-container" v-cloak>
    <div class="top-header">
        <h4 class="hd-title">我的优质老铁</h4>
        <div class="search-box"><input type="text" v-model='search' placeholder="输入账号或名称搜索" /></div>
        <div class="hd-tips">点击账号可直接复制，点击名称可查看详细资料</div>
        <div style="font-size: 12px; color: #d7d7d7; display: none;">following_count,mplatform_followers_count</div>
    </div>
    <div class="cube-list-rank">
        <div class="loading-box" v-if="total <= 0"><h4><i class="fa fa-spinner fa-pulse"></i> 数据加载中...</h4></div>
    	<dl class="data-list">
    		<dt class="d-title2" v-if="total > 0"><span>优质老铁</span><span class="s_total">共:{{total}}</span></dt>

            <dd class="data-list-hd" v-if="total > 0">
                <div class="item">账号</div>
                <div class="item">名称</div>
                <div class="item">关注</div> 
                <div class="item">粉丝</div>
            </dd>
    		<dd v-for="(v,index) in searchData">
                <div class="item" @click.stop="_copy(v.uid)">{{v.uid}}</div>
                <div class="item" @click.stop="open_details(v.sec_uid,v.real_follow,v.real_fans)"><i class="fa fa-home fa-fw"></i>{{v.uname}}</div>
                <div :class="['item', v.follow<100 ? 'c-red' : '']">{{v.follow}} <span class="open_details_btn" @click.stop="open_details(v.sec_uid)">看</span></div>
                <div class="item"><a href="javascript:;" :title="v.uname">{{v.fans}}</a></div>
                <a :href="'https://www.douyin.com/user/'+v.sec_uid" class="view_home" target="_blank">查看</a>
    			
    		</dd>
    	</dl>
        
    </div>

  <div class="div3" ><a class="open_dosub_box" href="javascript:;">添加老铁</a></div>
</div>



<div class="footer">
    <p>Powered by <a href="//www.d163.net/" target="_blank">Andyguo</a></p>
</div>

<div id="pop_dosub_box" class="pop-dosub-box">
    <div class="fix-pop-mask"></div>
    <div class="form-box-wrap animated ">
        <h4>添加优质老铁</h4>
        <form class="form1" onsubmit="return dosub(this)">
            <input type="hidden" name="dosubmit" value="1">
            <input type="hidden" name="modelid" value="6">
            <input type="hidden" name="tid" value="520">
            <div class="form-li">
                <input type="text" name="uid" placeholder="输入账号(必填项)" autocomplete="off">
            </div>
            <div class="form-li">
                <input type="text" name="uname" placeholder="输入名称" autocomplete="off">
            </div>
            <div class="form-li">
                <input type="text" name="follow" placeholder="关注数" autocomplete="off">
            </div>
            <div class="form-li">
                <input type="text" name="fans" placeholder="粉丝数" autocomplete="off">
            </div>
            <div class="form-li">
                <input type="text" name="sec_uid" placeholder="" autocomplete="off">
            </div>
            <div class="form-foot">
                <button type="submit">提交</button>
            </div>
        </form>
    </div>
</div>



<div id="goto-top"><a href="javascript:;"><i class="fa fa-arrow-up" aria-hidden="true"></i></a></div>
<script src="js/jquery.min.2.1.4.js"></script>
<script src="js/notiflix-aio-2.7.0.min.js"></script>
<script src="js/vue.min.js"></script>
<script src="js/axios.min.js"></script>

<script type="text/javascript">

    var vm = new Vue({
        el:'#app',
        data:{
            cubelistrank: [],
            search:"",
            total:0,
            apiurl: 'https://www.iesdouyin.com/web/api/v2/user/info/?sec_uid='
        },
        
        mounted(){
            this.getd()

        },
        methods: {
            getd:function() {
                let that = this;
                axios("https://wxycms.160.ink/index/douyin/getdatalist/tid/520").then(function(res) {
                    console.log(res);
                    that.cubelistrank = [];
                    that.cubelistrank.push(...res.data.data);
                    console.log(this.cubelistrank);
                    that.total = that.cubelistrank.length;
                })
            },
            // 复制操作
            _copy(context) {
                // 创建输入框元素
                let oInput = document.createElement('input');
                oInput.value = context;
                document.body.appendChild(oInput);
                oInput.select();
                document.execCommand('Copy');
                Notiflix.Notify.Success('复制成功');
                oInput.remove();
            },

            gotourl: function(url){
                if(url){
                    location.href = url;
                }
            },

            //弹窗
            open_details: function(sec_uid,real_follow,real_fans){
                if(!sec_uid) {
                    add_loading(2);
                    return;
                };
                $.ajax({
                    url: 'https://wxycms.160.ink/api/index/get_douyin_one/sec_uid/'+sec_uid,
                    type: 'GET',
                    beforeSend: function(){
                        add_loading(1);
                    },
                    success: function(res){
                        console.log(res);
                        $('.user_info_box_loading').remove();
                        if(res.data.status_code == 0){
                            var user_info = res.data.user_info;
                            var a = real_follow ? real_follow : user_info.following_count;
                            var b = real_fans ? real_fans : user_info.mplatform_followers_count;
                            var user_pic_uri = user_info.avatar_thumb ? user_info.avatar_thumb['uri'] : 'xx';
                            var user_id = user_info.short_id!=0 ? user_info.short_id : user_info.unique_id;
                            open_box_msg(user_info.nickname, user_info.signature, user_pic_uri, user_id, a, b, user_info.total_favorited, user_info.aweme_count,user_info.enterprise_verify_reason,user_info.custom_verify, user_info.secret, user_info.is_mix_user, user_info.mix_count, user_info.mix_info, user_info.card_entries)
                        }else{
                            add_loading(2);
                        }
                    }
                })
            }

        },

        created: function() {
            
        },
        computed:{
            okcuberank:function(){
                return sortKey(this.cubelistrank,'id');
            },
            searchData: function() {
                sortKey(this.cubelistrank,'id');
                var search = (this.search).toLowerCase();
                if (search) {
                    // 按所有字段搜索
                    return this.cubelistrank.filter(function(cuber) {
                        return Object.keys(cuber).some(function(key) {
                            let oK_value = String(cuber[key]).toLowerCase();
                            return oK_value.indexOf(search) > -1;
                        })
                    })
                    
                }
              
                return this.cubelistrank;
            }
            
        }
    })

function sortKey(array,key){
    return array.sort(function(a,b){
    var x = a[key];
    var y = b[key];
    return y-x;
    // return ((x<y)?-1:(x>y)?1:0)
    })
}


function dosub(obj){
    $.ajax({
        url: 'https://wxycms.160.ink/diyform/index/post.html',
        type: 'POST',
        dataType: 'JSON',
        data: $(obj).serialize(),
        success: function(res){
            if(res.status==1){
                Notiflix.Notify.Success('提交成功，感谢您的反馈。');
                $('#pop_dosub_box').removeClass('is_open');
                vm.getd();
                $('.form1')[0].reset();
            }else{
                Notiflix.Report.Info('系统提示',res.message);
            }
        }
    });

    return false;
}

function open_box_msg(nickname,signature,avatar,short_id,following_count,fans,total_favorited,aweme_count,enterprise_verify_reason,custom_verify,secret, is_mix_user, mix_count, mix_info, card_entries){
    var user_type = '', user_type_secret = '', user_heji = '', user_card_entries = '';
    if(secret==1){
        user_type_secret = '<span>私密账号</span>'
    }
    if(enterprise_verify_reason){
        // 店铺账号
        user_type = '<span class="user_type_company"><i class="fa fa-check-circle"></i> '+ enterprise_verify_reason +'</span>';
    }
    if(custom_verify){
        // 个人认证,如：音乐人
        user_type = '<span class="user_type_custom_verify"><i class="fa fa-check-circle"></i>'+ custom_verify +'</span>';
    }

    // 资料上展示的卡片,如：厨窗、直播动态
    if(card_entries && card_entries.length > 0){
        user_card_entries +='<div class="card_enter_box d-flex">';
        $.each(card_entries, function(i,val){
            if(val.type == 6 || val.type == 1 || val.type == 2){
                var icoSrc = val.icon_light.url_list[0];
                user_card_entries +='<a class="card_list_item d-flex" href="javascript:;">'+"\n";
                user_card_entries +='<div class="card_ico"><img src="'+icoSrc+'"> </div>'+"\n";
                user_card_entries +='<div class="card_text"><p>'+val.title+'</p> <p>'+val.sub_title+'</p> </div>'+"\n";
                user_card_entries +='</a>'+"\n";

            }
        })
        user_card_entries +='</div>'
    }

    // 作品合集
    if(Array.isArray(mix_info) && mix_info.length > 0){
        user_heji += '<div class="user_collection_box">';
        user_heji +='<div class="collection_label">合集:</div>';
        user_heji +='<div class="collection_list"><ul class="d-flex">';
        $.each(mix_info, function(i,val){
            user_heji +='<li class="collection_list_item">'+val.mix_name+'</li>'+"\n";
        })
        user_heji += '</ul></div>';
        user_heji += '</div>';
    }
    var user_pic_uri = 'https://p5.douyinpic.com/aweme/1080x1080/'+avatar+'.jpeg';
    var str = `<div class="user_info_box is_open">
                <div class="fix-pop-mask2"></div>
                <div class="user_info_box_content">
                    <div class="user-topimg"><img class="user_avatar_larger" src="${user_pic_uri}" alt="${nickname}"></div>

                    <div class="user_basic_info">
                        <h4>${nickname} ${user_type_secret}</h4>
                        <p class="user_short_id">${short_id} ${user_type}</p>
                        <div class="user_signature">${signature}</div>
                        
                    </div>
                    <div class="user_basic_info2"><span>关注:<s>${following_count}</s></span> <span>粉丝:<s>${fans}</s></span> <span>获赞:<s>${total_favorited}</s></span> <span>作品:<s>${aweme_count}</s></span></div>
                    ${user_card_entries}
                    ${user_heji}
                </div>
            </div>
    `;
    $('body').append($(str));
}

function add_loading(a=1){
    var txt = '<i class="fa fa-spinner fa-pulse"></i> 正在获取数据...';
    var class1 = '';
    if(a==1){
        txt = '<i class="fa fa-spinner fa-pulse"></i> 正在获取数据...';
    }else{
        txt = '<i class="fa fa-exclamation-circle"></i> 暂未获取到数据。';
        class1 = 'fix-pop-nodata';
    }
    var str = `<div class="user_info_box_loading">
                <div class="fix-pop-mask3 ${class1}"></div>
                <div class="user_info_box_content">
                    <div class="user-topimg"><img src="" alt=""></div>

                    <div class="user_basic_info">
                        <h4>${txt}</h4>
                        
                    </div>
                </div>
            </div>
    `;
    $('body').append($(str));
}

</script>

<script type="text/javascript">
    $(document).ready(function() {

        $('.open_dosub_box').on('click', function(){
            $('#pop_dosub_box').addClass('is_open');
            $('.fix-pop-mask').addClass('fadeIn');
            $('.form-box-wrap').addClass('fadeInDown')
        })

        $('.fix-pop-mask').on('click', function(){
            $('#pop_dosub_box').removeClass('is_open');
        })

        $(document).on('click', '.fix-pop-mask2', function(){
            console.log('ok')
            $('.user_info_box').remove();
        })

        $(document).on('click', '.fix-pop-nodata', function(){
            $('.user_info_box_loading').remove();
        })

        $(document).on('click', '.isclose_avatar', function(){
            $('.user_avatar_larger_pop_box').remove();
        })

        $(document).on('click', '.user_avatar_larger', function(){
            var imgSrc = $(this).attr('src');
            var str = `<div class="user_avatar_larger_pop_box">
                        <div class="fix-pop-mask4 isclose_avatar"></div>
                        <div class="preview_img_box isclose_avatar">
                            <img src="${imgSrc}">
                        </div>
                    </div>
            `;
            $('body').append($(str));
        })


        var _goToTop = $("#goto-top");
        $(window).scroll(function() {
            if ($(this).scrollTop() > 200) {
                _goToTop.fadeIn(200);
            } else {
                _goToTop.fadeOut(200);
            }
        });
        
        // Animate the scroll to top
        _goToTop.click(function(event) {
            event.preventDefault();
            $('html, body').animate({scrollTop: 0}, 300);
        })
    });

</script>

</body>


</html>
